#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f;

void solve()
{
	int n; string s;
	cin >> n >> s;
	unordered_map<char, int> mp;
	for (int i = 1; i < n - 1; i++)
	{
		if (++mp[s[i]] == 2)
		{
			cout << "yes" << endl;
			return;
		}
	}
	if (mp[s[0]] || mp[s.back()]) cout << "yes" << endl;
	else cout << "no" << endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _ = 1;
	cin >> _;
	while (_--)
	{
		solve();
	}
	return 0;
}